i have 10+ search requests common request fields may abstracted. example, 2 fields common across them similar following:
for common search
{ name: 'purple', guid: '1672d0cf-08dc-4c04-9ce2-a2e6e85d1d13', searchtype: 'common' }
for details on visit
{ name: 'purple', guid: '1672d0cf-08dc-4c04-9ce2-a2e6e85d1d13', visitid: 35 }
it nice following in apisearch.ts
import { search } './apimodels.ts' export class commonsearch extends search { public searchtype?: string; } export class visitrequestsearch extends search { public visitid: number; }
apimodals.ts
export class search { public name?: string; public guid?: string; }
i following error when try include base search
[at-loader] checking finished 1 errors [at-loader] src\app\apimodels.ts:12:44 ts2507: type 'any' not constructor function type.
my fiddler seems think abstraction if reasonable : https://jsfiddle.net/michael_shomsky/0bppt8dg/2/
so why error. started looking @ of documentation again (https://www.typescriptlang.org/docs/handbook/advanced-types.html) appears should using kind of intersection, i'm looking have library of available search requests, not factory; possibly there pattern or messed somewhere.
after fooling around various ways of doing realize there mistake in how file imported. apparently ts2507: type 'any' not constructor function type.
response missing super class (well, @ least in case).:
the following import got ".ts" removed , began working expected (similar jsfiddle)
import { search } './apimodels.ts';
needed
import { search } './apimodels';
Comments
Post a Comment