diff --git a/components/cascader/cascader.spec.ts b/components/cascader/cascader.spec.ts index d0398bc5005..2a863bf1ac4 100644 --- a/components/cascader/cascader.spec.ts +++ b/components/cascader/cascader.spec.ts @@ -2097,7 +2097,7 @@ export class NzDemoCascaderLoadDataComponent { label: 'Zhejiang' } ]; - resolve(); + resolve(null); } else if (index === 0) { node.children = [ { @@ -2105,7 +2105,7 @@ export class NzDemoCascaderLoadDataComponent { label: 'Hangzhou' } ]; - resolve(); + resolve(null); } else if (index === 1) { node.children = [ { @@ -2113,7 +2113,7 @@ export class NzDemoCascaderLoadDataComponent { label: 'West Lake' } ]; - resolve(); + resolve(null); } else { reject(); } diff --git a/components/modal/modal.spec.ts b/components/modal/modal.spec.ts index 3340c3462da..0507b1438c8 100644 --- a/components/modal/modal.spec.ts +++ b/components/modal/modal.spec.ts @@ -1167,7 +1167,7 @@ describe('NzModal', () => { onClick: () => { return new Promise(resolve => { setTimeout(() => { - resolve(); + resolve(null); }, 200); }); } @@ -1182,7 +1182,7 @@ describe('NzModal', () => { onClick: () => { return new Promise(resolve => { setTimeout(() => { - resolve(); + resolve(null); }, 200); }); } diff --git a/package.json b/package.json index 3e2865650e0..24b42c5836f 100644 --- a/package.json +++ b/package.json @@ -29,22 +29,22 @@ "resize-observer-polyfill": "^1.5.1" }, "devDependencies": { - "@angular-devkit/build-angular": "~0.1100.5", - "@angular-devkit/core": "^11.0.5", - "@angular-devkit/schematics": "^11.0.5", - "@angular/animations": "^11.0.5", - "@angular/cli": "~11.0.5", - "@angular/common": "^11.0.5", - "@angular/compiler": "^11.0.5", - "@angular/compiler-cli": "~11.0.5", - "@angular/core": "^11.0.5", - "@angular/forms": "^11.0.5", - "@angular/language-service": "^11.0.5", - "@angular/platform-browser": "^11.0.5", - "@angular/platform-browser-dynamic": "^11.0.5", - "@angular/platform-server": "^11.0.5", - "@angular/router": "^11.0.5", - "@angular/service-worker": "^11.0.5", + "@angular-devkit/build-angular": "~0.1101.0", + "@angular-devkit/core": "^11.1.0", + "@angular-devkit/schematics": "^11.1.0", + "@angular/animations": "^11.1.0", + "@angular/cli": "~11.1.0", + "@angular/common": "^11.1.0", + "@angular/compiler": "^11.1.0", + "@angular/compiler-cli": "~11.1.0", + "@angular/core": "^11.1.0", + "@angular/forms": "^11.1.0", + "@angular/language-service": "^11.1.0", + "@angular/platform-browser": "^11.1.0", + "@angular/platform-browser-dynamic": "^11.1.0", + "@angular/platform-server": "^11.1.0", + "@angular/router": "^11.1.0", + "@angular/service-worker": "^11.1.0", "@ant-design/dark-theme": "^2.0.2", "@commitlint/cli": "^11.0.0", "@commitlint/config-angular": "^11.0.0", @@ -100,7 +100,7 @@ "marked": "^1.2.7", "minimist": "^1.2.5", "monaco-editor": "^0.21.2", - "ng-packagr": "^11.0.3", + "ng-packagr": "^11.1.2", "ngx-color": "^6.2.0", "node-prismjs": "^0.1.2", "parse5": "^6.0.1", @@ -119,7 +119,7 @@ "ts-node": "~9.1.1", "tslib": "^2.0.3", "tslint": "~6.1.3", - "typescript": "~4.0.2", + "typescript": "~4.1.2", "yaml-front-matter": "^4.1.1", "zone.js": "~0.11.3" }, diff --git a/schematics/utils/build-component.ts b/schematics/utils/build-component.ts index 08f0ba44b0f..18d3875db73 100644 --- a/schematics/utils/build-component.ts +++ b/schematics/utils/build-component.ts @@ -7,7 +7,7 @@ */ import { strings, template as interpolateTemplate } from '@angular-devkit/core'; -import { ProjectDefinition, WorkspaceDefinition } from '@angular-devkit/core/src/workspace'; +import { ProjectDefinition } from '@angular-devkit/core/src/workspace'; import { apply, applyTemplates, @@ -25,11 +25,12 @@ import { import { FileSystemSchematicContext } from '@angular-devkit/schematics/tools'; import { getDefaultComponentOptions, getProjectFromWorkspace } from '@angular/cdk/schematics'; import { Schema as ComponentOptions, Style } from '@schematics/angular/component/schema'; +import * as ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript'; import { addDeclarationToModule, addEntryComponentToModule, addExportToModule, - getFirstNgModuleName + getDecoratorMetadata } from '@schematics/angular/utility/ast-utils'; import { InsertChange } from '@schematics/angular/utility/change'; import { buildRelativePath, findModuleFromOptions } from '@schematics/angular/utility/find-module'; @@ -39,7 +40,32 @@ import { getWorkspace } from '@schematics/angular/utility/workspace'; import { ProjectType } from '@schematics/angular/utility/workspace-models'; import { readFileSync, statSync } from 'fs'; import { dirname, join, resolve } from 'path'; -import * as ts from 'typescript'; + +function findClassDeclarationParent(node: ts.Node): ts.ClassDeclaration|undefined { + if (ts.isClassDeclaration(node)) { + return node; + } + + return node.parent && findClassDeclarationParent(node.parent); +} + +function getFirstNgModuleName(source: ts.SourceFile): string|undefined { + // First, find the @NgModule decorators. + const ngModulesMetadata = getDecoratorMetadata(source, 'NgModule', '@angular/core'); + if (ngModulesMetadata.length === 0) { + return undefined; + } + + // Then walk parent pointers up the AST, looking for the ClassDeclaration parent of the NgModule + // metadata. + const moduleClass = findClassDeclarationParent(ngModulesMetadata[0]); + if (!moduleClass || !moduleClass.name) { + return undefined; + } + + // Get the class name of the module ClassDeclaration. + return moduleClass.name.text; +} export interface ZorroComponentOptions extends ComponentOptions { classnameWithModule: boolean;