2018-10-26 18:50:12 +02:00
|
|
|
// @lib: es2015
|
|
|
|
// @traceResolution: true
|
|
|
|
|
2017-04-04 00:00:40 +02:00
|
|
|
// JSDoc typedef tags are not bound TypeScript files.
|
|
|
|
/** @typedef {function} T */
|
|
|
|
declare const x: T;
|
|
|
|
|
|
|
|
class T {
|
|
|
|
prop: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
x.prop;
|
2017-05-17 16:27:08 +02:00
|
|
|
|
|
|
|
// Just to be sure that @property has no impact either.
|
|
|
|
/**
|
|
|
|
* @typedef {Object} MyType
|
|
|
|
* @property {string} yes
|
|
|
|
*/
|
|
|
|
declare const myType: MyType; // should error, no such type
|
|
|
|
|
|
|
|
// @param type has no effect.
|
|
|
|
/**
|
|
|
|
* @param {number} x
|
|
|
|
* @returns string
|
|
|
|
*/
|
|
|
|
function f(x: boolean) { return x * 2; } // Should error
|
|
|
|
// Should fail, because it takes a boolean and returns a number
|
|
|
|
f(1); f(true).length;
|
|
|
|
|
|
|
|
// @type has no effect either.
|
|
|
|
/** @type {{ x?: number }} */
|
|
|
|
const z = {};
|
2017-06-09 23:52:01 +02:00
|
|
|
z.x = 1; // Error
|
|
|
|
|
|
|
|
// @template tag should not interfere with constraint or default.
|
|
|
|
/** @template T */
|
|
|
|
interface I<T extends number = 0> {}
|
|
|
|
|
|
|
|
/** @template T */
|
|
|
|
function tem<T extends number>(t: T): I<T> { return {}; }
|
|
|
|
|
|
|
|
let i: I; // Should succeed thanks to type parameter default
|
2017-06-12 23:35:35 +02:00
|
|
|
|
|
|
|
/** @typedef {string} N.Str */
|
|
|
|
import M = N; // Error: @typedef does not create namespaces in TypeScript code.
|
2017-06-15 19:02:16 +02:00
|
|
|
|
|
|
|
// Not legal JSDoc, but that shouldn't matter in TypeScript.
|
|
|
|
/**
|
|
|
|
* @type {{foo: (function(string, string): string)}}
|
|
|
|
*/
|
|
|
|
const obj = { foo: (a, b) => a + b };
|
2018-09-14 00:24:49 +02:00
|
|
|
|
|
|
|
/** @enum {string} */
|
|
|
|
var E = {};
|
|
|
|
E[""];
|
2018-10-26 18:50:12 +02:00
|
|
|
|
|
|
|
// make sure import types in JSDoc are not resolved
|
|
|
|
/** @type {import("should-not-be-resolved").Type} */
|
|
|
|
var v = import(String());
|