Reinforced.Typings icon indicating copy to clipboard operation
Reinforced.Typings copied to clipboard

TypeScript type in another assembly

Open thombrink opened this issue 6 years ago • 7 comments

Only when I'm using a class from another assembly I get the following waring:

Type resolvation warning RT0003: Could not find suitable TypeScript type for xxx. 'any' assumed.

I know I can use 'RtAdditionalAssembly' to fix it, but thats not what I want. This option generates TypeScript for all classes of the included assembly (as expected, but I only want to let the builder know where to get the class from).

thombrink avatar Nov 18 '19 15:11 thombrink

Could not find suitable TypeScript type for xxx. is being thrown when xxx was not exported (it is found, but you have not point RT to export it with attributes or fluent configuration). So RT simply reports it as warning in order to make it easier to find out why particular field/method/parameter has any type. Do not treat RT's warnings as errors.

pavel-b-novikov avatar Nov 18 '19 16:11 pavel-b-novikov

In order to get rid of this warning - you can explicitly use [TsProperty(Type = "any")] on the field that induces this error. Or use substitutions, or type inferers or just ignore it.

pavel-b-novikov avatar Nov 18 '19 16:11 pavel-b-novikov

I know it's possible to use the 'TsProperty' attribute, but I would expect diffrent behaviour.

Below some sample code to demonstrate my problem:

// Project A
// Reference to project B

[TsInterface]
class Foo : IBaz {
   Bar Bar {get; set;}
}

// Project B

[TsInterface]
class Bar {
}
[TsInterface]
interface IBaz {
}

will result in:

export interface IFoo extends B.IBaz {
   Bar: any;
}

but shoud result in:

export interface IFoo extends B.IBaz {
   Bar: B.Bar;
}

Why can Foo be extanded from Baz, but cant the property Bar be the correct type?

thombrink avatar Nov 18 '19 16:11 thombrink

That is strange. I will check in tests

pavel-b-novikov avatar Nov 18 '19 17:11 pavel-b-novikov

I am having this issue as well. @thombrink did you ever find a fix?

lukedukeus avatar Nov 03 '22 16:11 lukedukeus

I stopped using this nuget and switched to nswag.

thombrink avatar Nov 03 '22 17:11 thombrink

Was going to switch as well but found out you can fix this issue by adding the following to your Reinforced.Typings.settings.xml:

	<ItemGroup>
		<RtAdditionalAssembly Include="$(SolutionDir)\<otherproject>\bin\Debug\net6.0\<othernamespace.otherclass>.dll"/>
	</ItemGroup>

lukedukeus avatar Nov 03 '22 20:11 lukedukeus