diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4fde6a321a4..b9f33abe6c8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17434,6 +17434,7 @@ namespace ts { checkGrammarDecorators(node) || checkGrammarModifiers(node); checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0); + checkTypeParameters(node.typeParameters); checkSourceElement(node.type); } diff --git a/tests/baselines/reference/nounusedTypeParameterConstraint.js b/tests/baselines/reference/nounusedTypeParameterConstraint.js new file mode 100644 index 00000000000..aa403187f7a --- /dev/null +++ b/tests/baselines/reference/nounusedTypeParameterConstraint.js @@ -0,0 +1,14 @@ +//// [tests/cases/compiler/nounusedTypeParameterConstraint.ts] //// + +//// [bar.ts] + +export interface IEventSourcedEntity { } + +//// [test.ts] +import { IEventSourcedEntity } from "./bar"; +export type DomainEntityConstructor = { new(): TEntity; }; + +//// [bar.js] +"use strict"; +//// [test.js] +"use strict"; diff --git a/tests/baselines/reference/nounusedTypeParameterConstraint.symbols b/tests/baselines/reference/nounusedTypeParameterConstraint.symbols new file mode 100644 index 00000000000..40364460f50 --- /dev/null +++ b/tests/baselines/reference/nounusedTypeParameterConstraint.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/bar.ts === + +export interface IEventSourcedEntity { } +>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(bar.ts, 0, 0)) + +=== tests/cases/compiler/test.ts === +import { IEventSourcedEntity } from "./bar"; +>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(test.ts, 0, 8)) + +export type DomainEntityConstructor = { new(): TEntity; }; +>DomainEntityConstructor : Symbol(DomainEntityConstructor, Decl(test.ts, 0, 44)) +>TEntity : Symbol(TEntity, Decl(test.ts, 1, 36)) +>IEventSourcedEntity : Symbol(IEventSourcedEntity, Decl(test.ts, 0, 8)) +>TEntity : Symbol(TEntity, Decl(test.ts, 1, 36)) + diff --git a/tests/baselines/reference/nounusedTypeParameterConstraint.types b/tests/baselines/reference/nounusedTypeParameterConstraint.types new file mode 100644 index 00000000000..8f2de483d26 --- /dev/null +++ b/tests/baselines/reference/nounusedTypeParameterConstraint.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/bar.ts === + +export interface IEventSourcedEntity { } +>IEventSourcedEntity : IEventSourcedEntity + +=== tests/cases/compiler/test.ts === +import { IEventSourcedEntity } from "./bar"; +>IEventSourcedEntity : any + +export type DomainEntityConstructor = { new(): TEntity; }; +>DomainEntityConstructor : new () => TEntity +>TEntity : TEntity +>IEventSourcedEntity : IEventSourcedEntity +>TEntity : TEntity + diff --git a/tests/baselines/reference/typeAliasDeclarationEmit.errors.txt b/tests/baselines/reference/typeAliasDeclarationEmit.errors.txt new file mode 100644 index 00000000000..2fd71844dc4 --- /dev/null +++ b/tests/baselines/reference/typeAliasDeclarationEmit.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/typeAliasDeclarationEmit.ts(4,37): error TS2314: Generic type 'callback' requires 1 type argument(s). + + +==== tests/cases/compiler/typeAliasDeclarationEmit.ts (1 errors) ==== + + export type callback = () => T; + + export type CallbackArray = () => T; + ~~~~~~~~ +!!! error TS2314: Generic type 'callback' requires 1 type argument(s). \ No newline at end of file diff --git a/tests/cases/compiler/nounusedTypeParameterConstraint.ts b/tests/cases/compiler/nounusedTypeParameterConstraint.ts new file mode 100644 index 00000000000..d2c3a1677ee --- /dev/null +++ b/tests/cases/compiler/nounusedTypeParameterConstraint.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true + +//@filename: bar.ts +export interface IEventSourcedEntity { } + +//@filename: test.ts +import { IEventSourcedEntity } from "./bar"; +export type DomainEntityConstructor = { new(): TEntity; }; \ No newline at end of file diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts index 97027dfdd49..3d23ef3e961 100644 --- a/tests/webTestServer.ts +++ b/tests/webTestServer.ts @@ -128,7 +128,7 @@ function dir(dirPath: string, spec?: string, options?: any) { // fs.rmdirSync won't delete directories with files in it function deleteFolderRecursive(dirPath: string) { if (fs.existsSync(dirPath)) { - fs.readdirSync(dirPath).forEach((file, index) => { + fs.readdirSync(dirPath).forEach((file) => { const curPath = path.join(path, file); if (fs.statSync(curPath).isDirectory()) { // recurse deleteFolderRecursive(curPath); @@ -141,7 +141,7 @@ function deleteFolderRecursive(dirPath: string) { } }; -function writeFile(path: string, data: any, opts: { recursive: boolean }) { +function writeFile(path: string, data: any) { ensureDirectoriesExist(getDirectoryPath(path)); fs.writeFileSync(path, data); } @@ -208,7 +208,7 @@ enum RequestType { Unknown } -function getRequestOperation(req: http.ServerRequest, filename: string) { +function getRequestOperation(req: http.ServerRequest) { if (req.method === "GET" && req.url.indexOf("?") === -1) { if (req.url.indexOf(".") !== -1) return RequestType.GetFile; else return RequestType.GetDir; @@ -258,7 +258,7 @@ function handleRequestOperation(req: http.ServerRequest, res: http.ServerRespons break; case RequestType.WriteFile: processPost(req, res, (data) => { - writeFile(reqPath, data, { recursive: true }); + writeFile(reqPath, data); }); send(ResponseCode.Success, res, undefined); break; @@ -306,7 +306,7 @@ http.createServer((req: http.ServerRequest, res: http.ServerResponse) => { log(`${req.method} ${req.url}`); const uri = url.parse(req.url).pathname; const reqPath = path.join(process.cwd(), uri); - const operation = getRequestOperation(req, reqPath); + const operation = getRequestOperation(req); handleRequestOperation(req, res, operation, reqPath); }).listen(port);