feat(typescript): support definite assignment (`!:`) (#4020)

master
Ika 2018-02-22 01:40:57 +08:00 committed by GitHub
parent d298c51cba
commit 8f6a32853c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 6 deletions

View File

@ -35,6 +35,7 @@
"globby": "6.1.0",
"graphql": "0.12.3",
"gray-matter": "3.1.1",
"html-tag-names": "1.1.1",
"ignore": "3.3.7",
"jest-docblock": "22.2.2",
"json-stable-stringify": "1.0.1",
@ -54,9 +55,8 @@
"resolve": "1.5.0",
"semver": "5.4.1",
"string-width": "2.1.1",
"html-tag-names": "1.1.1",
"typescript": "2.7.0-insiders.20171214",
"typescript-eslint-parser": "13.0.0",
"typescript-eslint-parser": "14.0.0",
"unicode-regex": "1.0.1",
"unified": "6.1.6"
},

View File

@ -3214,7 +3214,7 @@ function printTypeAnnotation(path, options, print) {
}
return concat([
isFunctionDeclarationIdentifier ? "" : ": ",
isFunctionDeclarationIdentifier ? "" : node.definite ? "!: " : ": ",
path.call(print, "typeAnnotation")
]);
}

View File

@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`definite.ts 1`] = `
class MyComponent {
ngModel!: ng.INgModelController;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class MyComponent {
ngModel!: ng.INgModelController;
}
`;

View File

@ -0,0 +1,3 @@
class MyComponent {
ngModel!: ng.INgModelController;
}

View File

@ -0,0 +1 @@
run_spec(__dirname, ["typescript"]);

View File

@ -4579,9 +4579,9 @@ typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
typescript-eslint-parser@13.0.0:
version "13.0.0"
resolved "https://registry.yarnpkg.com/typescript-eslint-parser/-/typescript-eslint-parser-13.0.0.tgz#57f9be603d0fad7c26da76c2be67c0779d23362c"
typescript-eslint-parser@14.0.0:
version "14.0.0"
resolved "https://registry.yarnpkg.com/typescript-eslint-parser/-/typescript-eslint-parser-14.0.0.tgz#c90a8f541c1d96e5c55e2807c61d154e788520f9"
dependencies:
lodash.unescape "4.0.1"
semver "5.5.0"