mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Enable TS strict mode in all templates and generally clean up TS references
This commit is contained in:
@@ -1,11 +1,14 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"module": "es2015",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"skipDefaultLibCheck": true,
|
"skipDefaultLibCheck": true,
|
||||||
|
"skipLibCheck": true, // Workaround for https://github.com/angular/angular/issues/17863. Remove this if you upgrade to a fixed version of Angular.
|
||||||
|
"strict": true,
|
||||||
"lib": [ "es6", "dom" ],
|
"lib": [ "es6", "dom" ],
|
||||||
"types": [ "webpack-env" ]
|
"types": [ "webpack-env" ]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"module": "es2015",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"skipDefaultLibCheck": true,
|
"skipDefaultLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
"lib": [ "es2015", "dom" ],
|
"lib": [ "es2015", "dom" ],
|
||||||
"types": [ "webpack-env" ]
|
"types": [ "webpack-env" ]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import './css/site.css';
|
import './css/site.css';
|
||||||
import 'bootstrap';
|
import 'bootstrap';
|
||||||
import * as ko from 'knockout';
|
import * as ko from 'knockout';
|
||||||
|
import { createBrowserHistory } from 'history';
|
||||||
import './webpack-component-loader';
|
import './webpack-component-loader';
|
||||||
import AppRootComponent from './components/app-root/app-root';
|
import AppRootComponent from './components/app-root/app-root';
|
||||||
import { createBrowserHistory } from 'history';
|
|
||||||
const baseUrl = document.getElementsByTagName('base')[0].getAttribute('href')!;
|
const baseUrl = document.getElementsByTagName('base')[0].getAttribute('href')!;
|
||||||
const basename = baseUrl.substring(0, baseUrl.length - 1); // History component needs no trailing slash
|
const basename = baseUrl.substring(0, baseUrl.length - 1); // History component needs no trailing slash
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as ko from 'knockout';
|
import * as ko from 'knockout';
|
||||||
import * as $ from 'jquery';
|
import * as $ from 'jquery';
|
||||||
import * as History from 'history';
|
import * as History from 'history';
|
||||||
import crossroads = require('crossroads');
|
import * as crossroads from 'crossroads';
|
||||||
|
|
||||||
// This module configures crossroads.js, a routing library. If you prefer, you
|
// This module configures crossroads.js, a routing library. If you prefer, you
|
||||||
// can use any other routing library (or none at all) as Knockout is designed to
|
// can use any other routing library (or none at all) as Knockout is designed to
|
||||||
@@ -20,7 +20,7 @@ export class Router {
|
|||||||
// Reset and configure Crossroads so it matches routes and updates this.currentRoute
|
// Reset and configure Crossroads so it matches routes and updates this.currentRoute
|
||||||
crossroads.removeAllRoutes();
|
crossroads.removeAllRoutes();
|
||||||
crossroads.resetState();
|
crossroads.resetState();
|
||||||
crossroads.normalizeFn = crossroads.NORM_AS_OBJECT;
|
(crossroads as any).normalizeFn = crossroads.NORM_AS_OBJECT;
|
||||||
routes.forEach(route => {
|
routes.forEach(route => {
|
||||||
crossroads.addRoute(route.url, (requestParams: any) => {
|
crossroads.addRoute(route.url, (requestParams: any) => {
|
||||||
this.currentRoute(ko.utils.extend(requestParams, route.params));
|
this.currentRoute(ko.utils.extend(requestParams, route.params));
|
||||||
|
|||||||
18
templates/KnockoutSpa/npm-shrinkwrap.json
generated
18
templates/KnockoutSpa/npm-shrinkwrap.json
generated
@@ -21,9 +21,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/history": {
|
"@types/history": {
|
||||||
"version": "2.0.48",
|
"version": "4.6.0",
|
||||||
"from": "@types/history@>=2.0.38 <3.0.0",
|
"from": "@types/history@4.6.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/history/-/history-2.0.48.tgz",
|
"resolved": "https://registry.npmjs.org/@types/history/-/history-4.6.0.tgz",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/jquery": {
|
"@types/jquery": {
|
||||||
@@ -38,18 +38,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/knockout/-/knockout-3.4.41.tgz",
|
"resolved": "https://registry.npmjs.org/@types/knockout/-/knockout-3.4.41.tgz",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/react": {
|
|
||||||
"version": "15.0.31",
|
|
||||||
"from": "@types/react@*",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-15.0.31.tgz",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"@types/react-router": {
|
|
||||||
"version": "2.0.50",
|
|
||||||
"from": "@types/react-router@>=2.0.37 <3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/react-router/-/react-router-2.0.50.tgz",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"@types/signals": {
|
"@types/signals": {
|
||||||
"version": "0.0.16",
|
"version": "0.0.16",
|
||||||
"from": "@types/signals@0.0.16",
|
"from": "@types/signals@0.0.16",
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
"@types/history": "^4.6.0",
|
"@types/history": "^4.6.0",
|
||||||
"@types/jquery": "^2.0.32",
|
"@types/jquery": "^2.0.32",
|
||||||
"@types/knockout": "^3.4.41",
|
"@types/knockout": "^3.4.41",
|
||||||
"@types/react-router": "^2.0.37",
|
|
||||||
"@types/signals": "0.0.16",
|
"@types/signals": "0.0.16",
|
||||||
"@types/webpack-env": "^1.13.0",
|
"@types/webpack-env": "^1.13.0",
|
||||||
"aspnet-webpack": "^2.0.1",
|
"aspnet-webpack": "^2.0.1",
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"module": "es2015",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"skipDefaultLibCheck": true,
|
"skipDefaultLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
"types": ["es6-promise", "webpack-env"]
|
"types": ["es6-promise", "webpack-env"]
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export const actionCreators = {
|
|||||||
// ----------------
|
// ----------------
|
||||||
// REDUCER - For a given state and action, returns the new state. To support time travel, this must not mutate the old state.
|
// REDUCER - For a given state and action, returns the new state. To support time travel, this must not mutate the old state.
|
||||||
|
|
||||||
const unloadedState: WeatherForecastsState = { startDateIndex: undefined, forecasts: [], isLoading: false };
|
const unloadedState: WeatherForecastsState = { forecasts: [], isLoading: false };
|
||||||
|
|
||||||
export const reducer: Reducer<WeatherForecastsState> = (state: WeatherForecastsState, incomingAction: Action) => {
|
export const reducer: Reducer<WeatherForecastsState> = (state: WeatherForecastsState, incomingAction: Action) => {
|
||||||
const action = incomingAction as KnownAction;
|
const action = incomingAction as KnownAction;
|
||||||
|
|||||||
@@ -1,21 +1,16 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
|
"module": "es2015",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"skipDefaultLibCheck": true,
|
"skipDefaultLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
"lib": ["es6", "dom"],
|
"lib": ["es6", "dom"],
|
||||||
"types": [ "webpack-env" ],
|
"types": ["webpack-env"]
|
||||||
"paths": {
|
|
||||||
// Fix "Duplicate identifier" errors caused by multiple dependencies fetching their own copies of type definitions.
|
|
||||||
// We tell TypeScript which type definitions module to treat as the canonical one (instead of combining all of them).
|
|
||||||
"history": ["./node_modules/@types/history/index"],
|
|
||||||
"redux": ["./node_modules/@types/redux/index"],
|
|
||||||
"react": ["./node_modules/@types/react/index"]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"bin",
|
"bin",
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import { RouteComponentProps } from 'react-router';
|
||||||
|
|
||||||
interface CounterState {
|
interface CounterState {
|
||||||
currentCount: number;
|
currentCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Counter extends React.Component<{}, CounterState> {
|
export class Counter extends React.Component<RouteComponentProps<{}>, CounterState> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.state = { currentCount: 0 };
|
this.state = { currentCount: 0 };
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import { RouteComponentProps } from 'react-router';
|
||||||
import 'isomorphic-fetch';
|
import 'isomorphic-fetch';
|
||||||
|
|
||||||
interface FetchDataExampleState {
|
interface FetchDataExampleState {
|
||||||
@@ -6,7 +7,7 @@ interface FetchDataExampleState {
|
|||||||
loading: boolean;
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FetchData extends React.Component<{}, FetchDataExampleState> {
|
export class FetchData extends React.Component<RouteComponentProps<{}>, FetchDataExampleState> {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.state = { forecasts: [], loading: true };
|
this.state = { forecasts: [], loading: true };
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
import { RouteComponentProps } from 'react-router';
|
||||||
|
|
||||||
export class Home extends React.Component<{}, {}> {
|
export class Home extends React.Component<RouteComponentProps<{}>, {}> {
|
||||||
public render() {
|
public render() {
|
||||||
return <div>
|
return <div>
|
||||||
<h1>Hello, world!</h1>
|
<h1>Hello, world!</h1>
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
|
"module": "es2015",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"skipDefaultLibCheck": true,
|
"skipDefaultLibCheck": true,
|
||||||
"types": [ "webpack-env" ],
|
"strict": true,
|
||||||
"paths": {
|
"types": ["webpack-env"]
|
||||||
// Fix "Duplicate identifier" errors caused by multiple dependencies fetching their own copies of type definitions.
|
|
||||||
// We tell TypeScript which type definitions module to treat as the canonical one (instead of combining all of them).
|
|
||||||
"history": ["./node_modules/@types/history/index"],
|
|
||||||
"react": ["./node_modules/@types/react/index"]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"bin",
|
"bin",
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
"target": "es5",
|
"target": "es5",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"skipDefaultLibCheck": true,
|
"skipDefaultLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
"types": ["webpack-env"]
|
"types": ["webpack-env"]
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
|||||||
Reference in New Issue
Block a user