fireship-io / angular-tic-tac-toe Goto Github PK
View Code? Open in Web Editor NEWAngular Tic-Tac-Toe - A Tutorial for Beginners
Angular Tic-Tac-Toe - A Tutorial for Beginners
Error: src/app/board/board.component.ts:36:5 - error TS2322: Type 'string | null' is not assignable to type 'null'.
Type 'string' is not assignable to type 'null'.
36 this.winner = this.calculateWinner();
Am I the only one that the unit tests aren't working?
<?xml version="1.0"?>
<testsuite name="HeadlessChrome 78.0.3882 (Windows 10.0.0)" package="" timestamp="2019-09-26T15:13:25" id="0" hostname="PC-P-7330HK5" tests="5" errors="0" failures="4" time="0.681">
<properties>
<property name="browser.fullName" value="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/78.0.3882.0 Safari/537.36"/>
</properties>
<testcase name="AppComponent should render title" time="0.105" classname="HeadlessChrome_78_0_3882_(Windows_10_0_0).AppComponent">
<failure type="">1. If 'nb-layout-header' is an Angular component, then verify that it is part of this module.
2. If 'nb-layout-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<nb-layout>
[ERROR ->]<nb-layout-header fixed>
<!-- Insert header here -->
</nb-layout-header>
1. If 'app-board' is an Angular component, then verify that it is part of this module.
2. If 'app-board' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<nb-layout-column>
[ERROR ->]<app-board></app-board>
<router-outlet></router-outlet>
error properties: Object({ ngSyntaxError: true, ngParseErrors: [ 'nb-layout-header' is not a known element:
"): ng:///DynamicTestModule/AppComponent.html@2:2, 'app-board' is not a known element:
"): ng:///DynamicTestModule/AppComponent.html@8:4, 'nb-layout-column' is not a known element:
1. If 'nb-layout-column' is an Angular compon ...
at <Jasmine>
at syntaxError (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2175:1)
at TemplateParser.parse (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:11388:1)
at JitCompiler._parseTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25961:1)
at JitCompiler._compileTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25949:61)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1
at <Jasmine>
at JitCompiler._compileComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25813:1
at Object.then (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2166:27)
at JitCompiler._compileModuleAndAllComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25811:1)
</failure>
<failure type="">1. If 'nb-layout-header' is an Angular component, then verify that it is part of this module.
2. If 'nb-layout-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<nb-layout>
[ERROR ->]<nb-layout-header fixed>
<!-- Insert header here -->
</nb-layout-header>
1. If 'app-board' is an Angular component, then verify that it is part of this module.
2. If 'app-board' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<nb-layout-column>
[ERROR ->]<app-board></app-board>
<router-outlet></router-outlet>
error properties: Object({ ngSyntaxError: true, ngParseErrors: [ 'nb-layout-header' is not a known element:
"): ng:///DynamicTestModule/AppComponent.html@2:2, 'app-board' is not a known element:
"): ng:///DynamicTestModule/AppComponent.html@8:4, 'nb-layout-column' is not a known element:
1. If 'nb-layout-column' is an Angular compon ...
at <Jasmine>
at syntaxError (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2175:1)
at TemplateParser.parse (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:11388:1)
at JitCompiler._parseTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25961:1)
at JitCompiler._compileTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25949:61)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1
at <Jasmine>
at JitCompiler._compileComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25813:1
at Object.then (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2166:27)
at JitCompiler._compileModuleAndAllComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25811:1)
</failure>
</testcase>
<testcase name="AppComponent should create the app" time="0.074" classname="HeadlessChrome_78_0_3882_(Windows_10_0_0).AppComponent">
<failure type="">1. If 'nb-layout-header' is an Angular component, then verify that it is part of this module.
2. If 'nb-layout-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<nb-layout>
[ERROR ->]<nb-layout-header fixed>
<!-- Insert header here -->
</nb-layout-header>
1. If 'app-board' is an Angular component, then verify that it is part of this module.
2. If 'app-board' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<nb-layout-column>
[ERROR ->]<app-board></app-board>
<router-outlet></router-outlet>
error properties: Object({ ngSyntaxError: true, ngParseErrors: [ 'nb-layout-header' is not a known element:
"): ng:///DynamicTestModule/AppComponent.html@2:2, 'app-board' is not a known element:
"): ng:///DynamicTestModule/AppComponent.html@8:4, 'nb-layout-column' is not a known element:
1. If 'nb-layout-column' is an Angular compon ...
at <Jasmine>
at syntaxError (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2175:1)
at TemplateParser.parse (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:11388:1)
at JitCompiler._parseTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25961:1)
at JitCompiler._compileTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25949:61)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1
at <Jasmine>
at JitCompiler._compileComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25813:1
at Object.then (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2166:27)
at JitCompiler._compileModuleAndAllComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25811:1)
</failure>
<failure type="">1. If 'nb-layout-header' is an Angular component, then verify that it is part of this module.
2. If 'nb-layout-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<nb-layout>
[ERROR ->]<nb-layout-header fixed>
<!-- Insert header here -->
</nb-layout-header>
1. If 'app-board' is an Angular component, then verify that it is part of this module.
2. If 'app-board' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<nb-layout-column>
[ERROR ->]<app-board></app-board>
<router-outlet></router-outlet>
error properties: Object({ ngSyntaxError: true, ngParseErrors: [ 'nb-layout-header' is not a known element:
"): ng:///DynamicTestModule/AppComponent.html@2:2, 'app-board' is not a known element:
"): ng:///DynamicTestModule/AppComponent.html@8:4, 'nb-layout-column' is not a known element:
1. If 'nb-layout-column' is an Angular compon ...
at <Jasmine>
at syntaxError (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2175:1)
at TemplateParser.parse (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:11388:1)
at JitCompiler._parseTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25961:1)
at JitCompiler._compileTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25949:61)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1
at <Jasmine>
at JitCompiler._compileComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25813:1
at Object.then (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2166:27)
at JitCompiler._compileModuleAndAllComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25811:1)
</failure>
</testcase>
<testcase name="AppComponent should have as title 'myapp'" time="0.066" classname="HeadlessChrome_78_0_3882_(Windows_10_0_0).AppComponent">
<failure type="">1. If 'nb-layout-header' is an Angular component, then verify that it is part of this module.
2. If 'nb-layout-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<nb-layout>
[ERROR ->]<nb-layout-header fixed>
<!-- Insert header here -->
</nb-layout-header>
1. If 'app-board' is an Angular component, then verify that it is part of this module.
2. If 'app-board' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<nb-layout-column>
[ERROR ->]<app-board></app-board>
<router-outlet></router-outlet>
error properties: Object({ ngSyntaxError: true, ngParseErrors: [ 'nb-layout-header' is not a known element:
"): ng:///DynamicTestModule/AppComponent.html@2:2, 'app-board' is not a known element:
"): ng:///DynamicTestModule/AppComponent.html@8:4, 'nb-layout-column' is not a known element:
1. If 'nb-layout-column' is an Angular compon ...
at <Jasmine>
at syntaxError (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2175:1)
at TemplateParser.parse (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:11388:1)
at JitCompiler._parseTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25961:1)
at JitCompiler._compileTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25949:61)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1
at <Jasmine>
at JitCompiler._compileComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25813:1
at Object.then (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2166:27)
at JitCompiler._compileModuleAndAllComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25811:1)
</failure>
<failure type="">1. If 'nb-layout-header' is an Angular component, then verify that it is part of this module.
2. If 'nb-layout-header' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<nb-layout>
[ERROR ->]<nb-layout-header fixed>
<!-- Insert header here -->
</nb-layout-header>
1. If 'app-board' is an Angular component, then verify that it is part of this module.
2. If 'app-board' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<nb-layout-column>
[ERROR ->]<app-board></app-board>
<router-outlet></router-outlet>
error properties: Object({ ngSyntaxError: true, ngParseErrors: [ 'nb-layout-header' is not a known element:
"): ng:///DynamicTestModule/AppComponent.html@2:2, 'app-board' is not a known element:
"): ng:///DynamicTestModule/AppComponent.html@8:4, 'nb-layout-column' is not a known element:
1. If 'nb-layout-column' is an Angular compon ...
at <Jasmine>
at syntaxError (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2175:1)
at TemplateParser.parse (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:11388:1)
at JitCompiler._parseTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25961:1)
at JitCompiler._compileTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25949:61)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1
at <Jasmine>
at JitCompiler._compileComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25813:1
at Object.then (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2166:27)
at JitCompiler._compileModuleAndAllComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25811:1)
</failure>
</testcase>
<testcase name="BoardComponent should create" time="0.34" classname="HeadlessChrome_78_0_3882_(Windows_10_0_0).BoardComponent">
<failure type="">1. If 'app-square' is an Angular component and it has 'value' input, then verify that it is part of this module.
2. If 'app-square' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<app-square
*ngFor="let val of squares; let i = index"
[ERROR ->][value]="val"
(click)="makeMove(i)">
1. If 'app-square' is an Angular component, then verify that it is part of this module.
2. If 'app-square' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<main>
[ERROR ->]<app-square
error properties: Object({ ngSyntaxError: true, ngParseErrors: [ Can't bind to 'value' since it isn't a known property of 'app-square'.
"): ng:///DynamicTestModule/BoardComponent.html@13:8, 'app-square' is not a known element:
*ngFor="let val of squa ...
at <Jasmine>
at syntaxError (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2175:1)
at TemplateParser.parse (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:11388:1)
at JitCompiler._parseTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25961:1)
at JitCompiler._compileTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25949:61)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1
at <Jasmine>
at JitCompiler._compileComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25813:1
at Object.then (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2166:27)
at JitCompiler._compileModuleAndAllComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25811:1)
</failure>
<failure type="">1. If 'app-square' is an Angular component and it has 'value' input, then verify that it is part of this module.
2. If 'app-square' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
<app-square
*ngFor="let val of squares; let i = index"
[ERROR ->][value]="val"
(click)="makeMove(i)">
1. If 'app-square' is an Angular component, then verify that it is part of this module.
2. If 'app-square' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("
<main>
[ERROR ->]<app-square
error properties: Object({ ngSyntaxError: true, ngParseErrors: [ Can't bind to 'value' since it isn't a known property of 'app-square'.
"): ng:///DynamicTestModule/BoardComponent.html@13:8, 'app-square' is not a known element:
*ngFor="let val of squa ...
at <Jasmine>
at syntaxError (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2175:1)
at TemplateParser.parse (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:11388:1)
at JitCompiler._parseTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25961:1)
at JitCompiler._compileTemplate (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25949:61)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1
at <Jasmine>
at JitCompiler._compileComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25893:1)
at http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25813:1
at Object.then (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:2166:27)
at JitCompiler._compileModuleAndAllComponents (http://localhost:9876/_karma_webpack_/node_modules/@angular/compiler/fesm2015/compiler.js:25811:1)
</failure>
<failure type="">Error: Expected undefined to be truthy.
at <Jasmine>
at UserContext.<anonymous> (http://localhost:9876/_karma_webpack_/src/app/board/board.component.spec.ts:23:23)
at ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/node_modules/zone.js/dist/zone-evergreen.js:359:1)
at ProxyZoneSpec.push../node_modules/zone.js/dist/zone-testing.js.ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/node_modules/zone.js/dist/zone-testing.js:308:1)
</failure>
</testcase>
<testcase name="SquareComponent should create" time="0.096" classname="HeadlessChrome_78_0_3882_(Windows_10_0_0).SquareComponent"/>
<system-out>
<![CDATA[
]]>
</system-out>
<system-err/>
</testsuite>
In Board.Component.html
'''<app-square
*ngFor="let val of squares; let i = index"
[value] = "val"
(click)="makeMove(i)">
'''
brings an ERROR: "Type 'string' is not assignable to type '"X" | "O"'.ngtsc(2322)"
This is because the val of square is auto assigned String.
followed the Youtube tutorial and this Git Repo for reference and i cant seem to fix this ONE error only.
@codediodeio could be a piping issue with angular 12?
please help ๐ค๐
PS: Newbie in Angular Big fan of your channel and tutorials:hugs:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.